/**
 * @Project Name:hoofungson-elk-log
 * @Package Name:cn.hoofungson.framework.elk.log.util
 * @Since JDK 1.8
 */

package cn.hoofungson.framework.elk.log.util;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;

/**
 * @Description: 进程工具
 * @Author 胡松 hoofungson@163.com
 * @Date 2019-10-22 16:15
 * @Version V1.0
 */
public class ProcessUtils {

    /**
     * 进程ID
     **/
    private static String pid;

    private ProcessUtils() {
    }

    /**
     * 获取当前进程ID
     *
     * @return
     **/
    public static String getPid() {
        if (null == pid) {
            RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
            pid = runtimeMXBean.getName().split("@")[0];
        }
        return pid;
    }
}
